#include "kernel/types.h"
#include "user/user.h"

int
main(void)
{
  int p_p[2],p_c[2];
  char ball[2];
  pipe(p_p);
  pipe(p_c);
  int pid = fork();
  if(pid != 0){
    while(1){
      printf("pid: %d: received ping\n",getpid());
      write(p_p[1],"o",1);
      read(p_c[0],ball,1);
    }
  }
  else{
    while (1) {
      read(p_p[0],ball,1);
      printf("pid: %d: received pong\n",getpid());
      write(p_c[1],"o",1);
    }
  }
  exit(-1);
}